home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / console / svgatext.3 / svgatext / SVGATextMode-1.3 / wait_vsync.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-06  |  1.8 KB  |  68 lines

  1. /*  SVGATextMode -- An SVGA textmode manipulation/enhancement tool
  2.  *
  3.  *  Copyright (C) 1995,1996  Koen Gadeyne
  4.  *
  5.  *  This program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation; either version 2 of the License, or
  8.  *  (at your option) any later version.
  9.  *
  10.  *  This program is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  *  GNU General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU General Public License
  16.  *  along with this program; if not, write to the Free Software
  17.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20.  
  21. /***
  22.  *** wait_vsync.c: non-blocking V-blanking wait routine (doesn't hang when no VSYNC)
  23.  ***               waits until start of V-blanking interval.
  24.  ***/
  25.  
  26. #include <stdio.h>
  27. #include <values.h>
  28. #include <signal.h>
  29. #include <stdlib.h>
  30. #include <unistd.h>
  31. #include <sys/types.h>
  32. #include <sys/time.h>
  33. #ifndef DOS
  34. #  include <asm/io.h>
  35. #endif
  36.  
  37. #include "misc.h"
  38. #include "vga_prg.h"
  39. #include "wait_vsync.h"
  40. #include "messages.h"
  41.  
  42.  
  43. bool vtimeout=FALSE;   /* will be set TRUE if VSYNC times out */
  44.  
  45.  
  46. /* alarm fuction for when probe times out on too slow V-sync */
  47. void badsync(int signal)
  48. {
  49.   PWARNING(("Slow sync. Possibly no, or very slow clock (vertical refresh < 1 Hz).\n"));
  50.   vtimeout=TRUE;
  51. }
  52.  
  53.  
  54. int safe_wait_vsync()
  55. {
  56.   /* check if vertical refresh is "reasonable" , and avoid "hangup" when something is really wrong */
  57.   vtimeout=FALSE;
  58.   PDEBUG(("Checking for Slow Sync...\n"));
  59.   signal(SIGALRM, badsync);
  60.   alarm(2);
  61.   wait_vblk;
  62.   alarm(0);
  63.   signal(SIGALRM, SIG_DFL);
  64.   return(!vtimeout);
  65. }
  66.  
  67.  
  68.